import { ajax } from "../../utils/ajax";
const form = document.forms[0];

form.onsubmit = form_submit;
function form_submit(e) {
    e.preventDefault();
    const username = form.username.value;
    const password = form.password.value;
    ajax.post('post', '/api/admin/login', { username, password }).then(result => {
        if (result.flag) {
            localStorage.setItem('token', result.token);
            alert(result.msg);
            location.replace('../../backStage.html');
        } else {
            alert(result.msg);
            form.reset();
        }
    })
}

